<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>未取数出入库单据</title>
</head>
<body>
<div id="NotSavedStockList_toolbar" style="height: auto;width: 100%;text-align: center">
    <p style="font-size: 30px;color: #0081c2">未取数出入库单据</p>
    <div style="width: 100%;height: 60px;">
        <form id="NotSavedStockList_form" role="form" method="post">
        <label style="font-size: 20px">查询单据类型: </label>
        <select id="selectCodeH" style="width: 160px;height: 29px;border-radius: 5px;">
            <option selected value="">请选择单据类型(必选)</option>
            <option value="1">销售出库单</option>
            <option value="2">调拨出库单</option>
            <option value="3">产成品入库单</option>
        </select>
        <label style="font-size: 20px;margin-left: 10px">查询类型: </label>
        <input id="notSavedStartTime" data-options="prompt:'查询必选项'"
               style="width:183px" class="easyui-datebox" editable="false" required="required"/>
        —
        <input id="notSavedEndTime" class="easyui-datebox" editable="false"
               data-options="required :'required',prompt:'查询必选项'"/>
            <a href="#" class="easyui-linkbutton" style="width: 80px;height: 30px;margin-left: 10px"
               data-options="iconCls:'icon-search'" onclick="NotSavedStockList_btnRefresh()">查询</a>
            <a href="#" id="crop" class="easyui-linkbutton" style="width: 100px;height: 30px;margin-left: 10px;"
               data-options="iconCls:'icon-save'" onclick="NotSavedStockList_Excel()">导出Excel</a>
        </form>
    </div>
</div>
<table id="NotSavedStockList_table" class="easyui-datagrid" rownumbers="true"
       toolbar="#NotSavedStockList_toolbar" pagination="true" style="width:100%;height:100%"
       data-options="pageSize: 20,pageList: [20,50,100]"/>

<script th:inline="none" type="text/javascript">

    function NotSavedStockList_btnRefresh() {
        var notSavedStartTime = $("#notSavedStartTime").val();
        var notSavedEndTime = $("#notSavedEndTime").val();
        var selectCodeH = $("#selectCodeH").val();
        if (selectCodeH != '') {
            if (notSavedEndTime != '' && notSavedStartTime != '') {
                $("#NotSavedStockList_table").datagrid("load", {
                    selectCodeH: selectCodeH,
                    notSavedEndTime: notSavedEndTime,
                    notSavedStartTime: notSavedStartTime
                });
                if (selectCodeH == 1) {
                    $("#NotSavedStockList_table").datagrid({
                        url: '/notSavedStockList/getNotSavedStockList',
                        onLoadSuccess: function (data) {
                            if (data == null || data.total == 0) {
                                topCommonMessage("没有相关的数据!")
                            }
                        },
                        columns: [[
                            {field: 'vbillcode', title: '单据号', width: 138, align: 'center'},
                            {field: 'dbilldate', title: '单据日期', width: 140, align: 'center'},
                            {field: 'clName', title: '仓库', width: 100, align: 'center'},
                            {field: 'wlCode', title: '物料编码', width: 100, align: 'center'},
                            {field: 'wlName', title: '物料名称', width: 200, align: 'center'},
                            {field: 'nshouldassistnum', title: '应收数量', width: 100, align: 'center'},
                            {field: 'nshouldnum', title: '应收主数量', width: 100, align: 'center'},
                            {field: 'nnum', title: '实收主数量', width: 100, align: 'center'},
                            {field: 'vbatchcode', title: '批次号', width: 120, align: 'center'},
                            {field: 'vnotebody', title: '行备注', width: 80, align: 'center'},
                            {field: 'vfirstbillcode', title: '源头单据号', width: 120, align: 'center'},
                            {field: 'materialspec', title: '规格', width: 120, align: 'center'},
                            {field: 'materialtype', title: '型号', width: 120, align: 'center'},
                        ]]
                    })
                } else {
                    $("#NotSavedStockList_table").datagrid({
                        url: '/notSavedStockList/getNotSavedStockList',
                        onLoadSuccess: function (data) {
                            if (data == null || data.total == 0) {
                                topCommonMessage("没有相关的数据!")
                            }
                        },
                        columns: [[
                            {field: 'vbillcode', title: '单据号', width: 138, align: 'center'},
                            {field: 'dbilldate', title: '单据日期', width: 140, align: 'center'},
                            {field: 'clName', title: '仓库', width: 100, align: 'center'},
                            {field: 'wlCode', title: '物料编码', width: 100, align: 'center'},
                            {field: 'wlName', title: '物料名称', width: 200, align: 'center'},
                            {field: 'nshouldassistnum', title: '应发数量', width: 100, align: 'center'},
                            {field: 'nshouldnum', title: '应发主数量', width: 100, align: 'center'},
                            {field: 'nnum', title: '实发主数量', width: 100, align: 'center'},
                            {field: 'vbatchcode', title: '批次号', width: 120, align: 'center'},
                            {field: 'vnotebody', title: '行备注', width: 80, align: 'center'},
                            {field: 'vfirstbillcode', title: '源头单据号', width: 120, align: 'center'},
                            {field: 'materialspec', title: '规格', width: 120, align: 'center'},
                            {field: 'materialtype', title: '型号', width: 120, align: 'center'},
                        ]]
                    })
                }
            } else {
                topCommonMessage("请选择日期范围!")
            }
        } else {
            topCommonMessage("请选择查询单据类型!")
        }
    }

    function NotSavedStockList_Excel() {
        var notSavedStartTime = $("#notSavedStartTime").val();
        var notSavedEndTime = $("#notSavedEndTime").val();
        var selectCodeH = $("#selectCodeH").val();
        if (selectCodeH != '') {
            if (notSavedEndTime != '' && notSavedStartTime != '') {
                $("#NotSavedStockList_form").form('submit',{
                    url:"/notSavedStockList/notSavedStockOutExcel?selectCodeH="+selectCodeH+"&notSavedStartTime="+notSavedStartTime+"&notSavedEndTime="+notSavedEndTime,
                })
                // 监听导出结束
                listenEnd();
                //等待层
                await();
                $("#crop").css("color", "#CCC");
                $('#crop').linkbutton('disable');
            } else {
                topCommonMessage("请选择日期范围!")
            }
        } else {
            topCommonMessage("请选择查询单据类型!")
        }
    }
</script>
</body>
</html>